package ko;

import java.util.Hashtable;

import ko.util.IListener;
import ko.util.KEventObject;

public class KEvent {
	public static final String COMPLETE = "Complete";
	
	private Hashtable<String,IListener> events = new Hashtable<String,IListener>();
	
	public synchronized void addEventListener(String event,IListener listener) {
		events.put(event, listener);
	}
	
	public synchronized void removeEventListener(String event) {
		events.remove(event);
	}

	protected void dispatchEvent(Object obj,String key) {
		KEventObject e = new KEventObject(obj);
		synchronized (obj) {
			IListener listener = events.get(key);
			if(listener != null) listener.EventActivated(e);
		}
	}
}
